﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "GnufBase.h"
#include "GnufQtObjectPtr.h"

namespace gnuf {
    class Pallet;
    class QtMessageBoard;
    class Info;

    enum class MessageReturnValue
    {
        eInvalid = -1,
        // 与  MsgBoardReturnValue::eIDCLOSE 对齐
        eCancel = -2
    };

    class GNUF_BASE_EXPORT MessageBoard final
    {
    public:
        MessageBoard(
            const std::wstring& caption,
            const std::wstring& text,
            const std::list<std::wstring>& buttons = {},
            int currentButton = 0);
        virtual ~MessageBoard();

        int popup(int posX, int posY, unsigned long long wId = 0);

        const std::wstring& caption() const { return m_caption; }
        const std::wstring& text() const { return m_text; }
        const std::list<std::wstring>& buttons() const { return m_buttons; }
        int currentButton() const { return m_currentButton; }

        void setButtonClicked(int buttonClicked) { m_buttonClicked = buttonClicked; }
        int buttonClicked() const { return m_buttonClicked; }

        void setContentWidth(int width) { m_width = width; }
        int getContentWidth() { return m_width; }

        void setAuxiliaryText(const std::wstring& text) { m_auxiliaryText = text; }
        const std::wstring& auxiliaryText() const { return m_auxiliaryText; }

        void addButton(const std::wstring& str) { m_buttons.push_back(str); }
        void addFrontIcon(gcmp::OwnerPtr< Info >& info);
        const Info* getFrontIcon() const { return m_frontIcon.get(); }

        Pallet* pallet() { return m_pallet.get(); }

        struct Margin
        {
            int left;
            int top;
            int right;
            int bottom;
        } contentMargin;

    private:
        std::wstring m_caption;
        std::wstring m_text;
        std::wstring m_auxiliaryText;
        std::list<std::wstring> m_buttons;
        int m_currentButton;
        gcmp::QtAutoPtr<QtMessageBoard> m_qtMessageBoard;
        gcmp::OwnerPtr<Pallet> m_pallet;
        int m_buttonClicked;
        int m_width;
        gcmp::OwnerPtr<Info> m_frontIcon;
    };

}
